home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0014_STRNGSF4.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  114 lines

  1. {
  2. This code has been slightly shrunk to fit into one message.
  3. }
  4.  
  5. Program input;
  6. Uses
  7.   Dos, Crt;
  8.  
  9. Const
  10.   Word_wrap = 50;
  11.  
  12. Var
  13.   tick,
  14.   mlines  : Integer;
  15.   modem   : String[1];
  16.   incom,
  17.   waiting : String[128];
  18.  
  19. Procedure outread(avr1, avr2, avr3 : Integer);
  20.  
  21. Var                      { avr1= 1=passWord, 2=normal                   }
  22.   i,y,o,                 { avr2= 1=none, 2=Word wrap                    }
  23.   count:Integer;         { avr3= 1=pull from String, 2=none             }
  24.   Word:String[10]; Charout:Char;
  25.  
  26. begin
  27.   incom:=''; count:=0; mlines:=0;
  28.   if avr3=2 then waiting:='';
  29.   if avr3=1 then if waiting<>'' then
  30.     begin
  31.       incom:=waiting;
  32.       waiting:='';
  33.       Write(incom);
  34.       count:=length(incom);
  35.     end;
  36.   modem:=''; TextColor(3);
  37.   While modem<>chr(13) do
  38.     begin
  39.       Charout:=ReadKey; modem:=Charout;
  40.       Case ord(modem[1]) of
  41.         13:begin             { return }
  42.              Writeln; Exit;
  43.            end;
  44.          8:begin             { backspace }
  45.              if count>0 then
  46.                begin
  47.                  Write(chr(8)+chr(32)+chr(8));
  48.                  delete(incom,count,1);
  49.                  count:=count-1;
  50.                end;
  51.              modem:='';
  52.            end;
  53.          9:begin             { tab }
  54.              Write('     '); incom:=incom+'     '; count:=count+5;
  55.              modem:='';
  56.            end;
  57.         10:modem:='';        { line feed }
  58.     1..26,
  59.    28..31,
  60.   128..255:begin             { inappropriate Characters }
  61.              modem:='';
  62.            end;
  63.       end;
  64.       if modem<>'' then
  65.         begin
  66.           count:=count+1;
  67.           if count<Word_wrap then
  68.             begin
  69.               incom:=incom+modem;
  70.               Case avr1 of
  71.                 1:Write('?');
  72.                 5:Write;
  73.                 else Write(modem);
  74.               end;
  75.             end else if avr2=2 then
  76.               begin
  77.                 waiting:='';
  78.                 For i:=length(incom) DownTo 1 do
  79.                   begin
  80.                     Write(chr(8)+chr(32)+chr(8));
  81.                     Word:=copy(incom,i,1);
  82.                     if Word=chr(32) then
  83.                       begin
  84.                         waiting:=copy(incom,i+1,length(incom));
  85.                         waiting:=waiting+modem;
  86.                         delete(incom,i,length(incom)); Writeln; Exit;
  87.                       end;
  88.                    end;
  89.               end;
  90.         end;
  91.     end; { waiting For modem to = chr(13) }
  92.   if avr1 <> 5 then Writeln;
  93. end; { end of Procedure }
  94.  
  95. begin
  96.   ClrScr;
  97.   TextColor(15);
  98.   Write('This is a passWord input: ');
  99.   outread(1,1,2);
  100.   TextColor(11);
  101.   Writeln('Return = ',incom);
  102.   TextColor(15);
  103.   Write('This is a normal input: ');
  104.   outread(2,1,2);
  105.   TextColor(11);
  106.   Writeln('Return = ',incom);
  107.   TextColor(15);
  108.   Writeln('This is a controlled Word-wrap input at length 50:');
  109.   Writeln;
  110.   tick := 0;
  111.   For tick := 1 to 5 do
  112.     outread(2, 2, 1);
  113. end.
  114.